package com.allwees.bs.core.model.order.entity;

import com.baomidou.mybatisplus.core.toolkit.ArrayUtils;
import com.allwees.bs.core.modelbase.entity.BaseEntity;
import com.allwees.core.common.util.StringUtil;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

import javax.persistence.Column;
import javax.persistence.MappedSuperclass;
import java.math.BigDecimal;

@Data
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
@MappedSuperclass
public class SkuSnapModel extends BaseEntity {
    @Column(length = 48, updatable = false)
    protected String orderUuid;

    @Column(length = 48, updatable = false)
    protected String orderItemUuid;

    @Column(length = 48, updatable = false)
    protected String supplierUuid;

    @Column(length = 48, updatable = false)
    protected String retailerUuid;

    @Column(length = 48, updatable = false)
    protected String storeUuid;

    @Column(length = 32)
    protected String productNo;

    @Column(length = 48, updatable = false)
    protected String productUuid;

    @Column(length = 512)
    protected String productName;

    @Column(length = 8192)
    protected String productPhoto;

    private Boolean freeGiftProd;

    private Integer marketingType;

    @Column(columnDefinition = "text")
    protected String productDesc;

    @Column(length = 64)
    protected String productShippingArrivalDesc;

    @Column(length = 12)
    protected String categoryNo;

    @Column(length = 32)
    protected String skuNo;

    @Column(length = 48, updatable = false)
    protected String skuUuid;

    @Column(length = 48)
    protected String skuColor;

    @Column(length = 48)
    protected String skuSize;

    /** sku 图片 **/
    @Column(length = 4096)
    protected String photosStr;

    // 商品原价
    @Column(precision = 8, scale = 2)
    protected BigDecimal skuOriginPrice;

    // 商品零售价
    @Column(precision = 8, scale = 2)
    protected BigDecimal skuRetailPrice;

    protected Integer quantity;

    @Column(precision = 8, scale = 2)
    protected BigDecimal skuShippingPrice;

    /**
     * sku加价后运费
     */
    @Column(precision = 8, scale = 2)
    protected BigDecimal skuShippingPriceAfterAdd;

    @Column(length = 4)
    protected String skuShippingCurrency;

    @Column(length = 4)
    protected String currency;

    // 商品单价
    @Column(precision = 8, scale = 2)
    protected BigDecimal price;

    // 供应价
    @Column(precision = 8, scale = 2)
    protected BigDecimal supplyPrice;


    // sku原始税费
    @Column(precision = 8, scale = 2)
    protected BigDecimal originalAmtSaleTaxSku;

    // sku加价后税费
    @Column(precision = 8, scale = 2)
    protected BigDecimal amtSaleTaxSkuAfterAdd;


    // sku自定义编号
    protected String skuCustomNo;


    //买家id

    protected String userUuid;

    //加价后sku实付(skuAmtAfterAdd = skuShippingPriceAfterAdd + skuAmtProductAfterAdd )
    protected  BigDecimal skuAmtAfterAdd;

    //加价后sku商品实付
    protected  BigDecimal skuAmtProductAfterAdd;

	public String[] getPhotos() {
		return StringUtil.splitToArray(getPhotosStr());
	}

	public void setPhotos(String[] photos) {
		setPhotosStr(ArrayUtils.isEmpty(photos) ? null : StringUtils.join(photos, ","));
	}
}
